<template>
    <div class="warp">
        <div class="banner">
            <img src="../../assets/reviews/icon_banner.png" alt="">
        </div>
        <div class="content">
            <div class="minTitle">
                <div class="flag"></div>
                <div class="text">评审公告</div>
            </div>
            <div class="container">
                <div v-for="item in dataList" :key="item.id">
                    <label v-if="item.type == 1">军人干部</label>
                    <label v-if="item.type == 2">文职人员</label>
                    <p>{{titles[item.typeStatus-1]}}</p>
                    <p>{{item.roundText}}</p>
                    <p class="color-special">{{item.startTime}}至{{item.endTime}}</p>
                    <span v-if="item.reviewActive==1">未开始</span>
                    <span class="active" v-if="item.reviewActive==2" @click="handleToexpert(item)">点击进入</span>
                    <span class="active"  v-if="item.reviewActive==3" @click="handleToexpert(item)">回看</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import Qs from 'qs'
    import { findExpertTask } from '@/service/api'
    export default {
        name: "expertNotice",
        data() {
            return {
                titles:['续任正高','晋升正高','续任副高','晋升副高','续任中职','晋升中职'],
                dataList:[],
                setItFindExpertTask:null,
            }
        },
        created() {
            this.inits();
            this.setItFindExpertTask = setInterval(()=>{
                this.inits()
            },60000)
        },
        methods:{
            inits() {
                findExpertTask().then(res => {  //
                    if (res.code == 200) {
                        this.dataList = [];
                        let rounds = null;
                        res.data.forEach(item=>{
                            rounds = item.rounds.split('-');
                            // console.log(rounds.length)
                            if(rounds[0] == 1){
                                item.roundText = `第一轮第${rounds.length}次配置`
                            }else {
                                item.roundText = `第二轮第${rounds.length}次配置`
                            }
                            if(new Date(item.startTime) > new Date()){
                                item.reviewActive = 1;
                            }else if(item.commit == '0'){
                                item.reviewActive = 2;
                            }else if(item.commit == '1'){
                                item.reviewActive = 3;
                            }
                            this.dataList.push(item)

                        })
                        // console.log(this.dataList)
                    } else {
                        console.log(res)
                    }
                });
            },
            handleToexpert(item){
                let params = {
                    rounds:item.rounds,
                    typeStatus:item.typeStatus,
                    type:item.type
                }
                this.$router.push({name:"expertReviews",params:params});
            },
            objToArray (array) {
                let arr = []
                for (let i in array) {
                    arr.push(array[i]);
                }
                return arr;
            }
        },
        beforeDestroy() {
            clearInterval(this.setItFindExpertTask)
        }
    }
</script>

<style scoped>
    .warp{
        height: 100%;
        min-width: 800px;
        background: rgba(255, 255, 255, 1);
        box-shadow: 0px 9px 8px 2px rgba(43, 103, 254, 0.05);
        border-radius: 5px;
        overflow: hidden;
    }
    .banner{
        /*width: 96%;*/
        margin: 22px 38px;
        height: 44%;
    }
    .banner img{
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
    }
    .content{
        margin: 0px 38px;
        height: 38%;
    }
    .minTitle{
        display: flex;
        flex-direction: row;
        align-items: center;
        background: #31478f0d;
        padding: 14px 0px;
        border-top: solid 1px #f3f3f3;
        position:relative;
    }
    .minTitle>.flag{
        width: 3px;
        background: #31478F;
        margin: auto 22px;
        height: 18px;
    }
    .minTitle>.text{
        color: #31478F;
        font-weight: bold;
        font-size: 17px;
    }
    .container{
        margin-top: 6px;
        height: 100%;
        overflow: auto;
    }
    .container > div{
        width: 80%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-left: 50px;
        background: url("../../assets/reviews/icon_dian@2x.png") no-repeat 18px;
        background-size: 18px 18px;
        margin-top: 24px;
    }
    .container div span{
        display: block;
        font-size: 15px;
        font-weight: bold;
        color: #C0C4CC;
        width: 68px;
    }
    .container div span.active{
        color: #2ECA61;
        cursor: pointer;
    }
    .container div p{
        font-size: 15px;
        font-weight: bold;
        color: #333333;
    }
    .container div label{
        display: block;

        font-weight: bold;

    }
    .container div .color-special{
        color: #31478F;
        font-size: 16px;
    }
</style>
